package de.grosjohann.android.feuerwehr.webservice;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.http.HttpException;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;

public class C2DMWsClient
  extends WsClient {

  C2DMWsClient(String newUri, int connectionTimeout, int socketTimeout) throws ClientProtocolException, IOException {
    super(newUri, connectionTimeout, socketTimeout);
  }

  int post(NameValuePair... params) throws ClientProtocolException, IOException, HttpException {
    HttpPost httpPost = new HttpPost(uri);

    List<NameValuePair> postParams = new ArrayList<NameValuePair>();
    postParams.addAll(Arrays.asList(params));
    httpPost.setEntity(new UrlEncodedFormEntity(postParams));

    HttpResponse resp = hc.execute(httpPost);

    return resp.getStatusLine().getStatusCode();
  }

}
